{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=111
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	x,y,p,kk:longint;
	s,t:string;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
x:=0;
y:=0;
while not eof do begin
	readln(S);
	kk:=pos(' ',s);
	t:=copy(s,1,kk-1);
	delete(s,1,kk);
	p:=strtoint(s);
	if t='North' then inc(y,p) else
	if t='South' then dec(y,p) else
	if t='East' then inc(x,p) else dec(x,p);
end;
write(x,' ',y);
end.